package com.example.demo.service.Impl;


import com.example.demo.dao.IQx;
import com.example.demo.model.Qx;
import com.example.demo.service.IQxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator 张喜英
 */

@Service
public class QxServiceImpl implements IQxService{

    @Autowired
    private IQx qxMapper;
    @Override
    public int insertQx(Qx qx){
        int qxValue=0;

        Qx qx1=new Qx();
        qx1.setQxid(qx.getQxid());
        List<Qx> getU=qxMapper.getAllQx(qx1);
        if(getU.size()>=1){
            qxValue=-1;

        }else{
            qxValue=qxMapper.insertQx(qx);
        }

        return qxValue;
    }

    @Override
    public List<Qx> getAllQx(Qx qx) {


        return qxMapper.getAllQx(qx);
    }

    @Override
    public int updateQx(Qx qx) {
        int qxValues=0;
        if(qx.getQxid()!=0){



            qxValues=qxMapper.updateQx(qx);
        }
        return qxValues;
    }

    @Override
    public int deleteQx(Qx qx) {
        int qxValues=0;
        if(qx.getQxid()!=0)
        {
            //主键是否与其他表有关联

            qxValues=qxMapper.deleteQx(qx);
        }
        return qxValues;
    }

    @Override
    public Qx getQx(Qx qx) {
        Qx qx1=new Qx();
        if(qx.getQxid()!=0){
            qx1=qxMapper.getQx(qx);
        }
        return qx1;
    }

}
